package com.liuyandog.server;

import com.liuyandog.pojo.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

public class UserInfoServer extends UserUI {
    /*个人信息界面*/
    JLabel lName, lId, lSex, lFaculty, lMajor, lAge, lEmail, lTel;
    JTextField tName, tId, tSex, tFaculty, tMajor, tAge, tEmail, tTel;
    JButton save;
    User user;
    public UserInfoServer(){
        super();
        lName = new JLabel("姓名");
        lId = new JLabel("账号");
        lSex = new JLabel("性别");
        lFaculty = new JLabel("院系");
        lMajor = new JLabel("专业");
        lAge = new JLabel("年龄");
        lEmail = new JLabel("邮箱");
        lTel = new JLabel("电话");
    }
    public UserInfoServer(User user){
        this();
        setLayout(new FlowLayout());
        this.user = user;

        tName = new JTextField(user.name,20);
        tId = new JTextField(String.valueOf(user.ID),20);
        tSex = new JTextField(user.sex,20);
        tFaculty = new JTextField(user.faculty,20);
        tMajor = new JTextField(user.major,20);
        tAge = new JTextField(String.valueOf(user.age),20);
        tEmail = new JTextField(user.email,20);
        tTel = new JTextField(String.valueOf(user.tel),20);

        save = new JButton("保存");//修改信息时保存
        save.addActionListener(this);
        //设置标签、文本与按钮位置
        /*
        lName.setBounds();
        lId.setBounds();
        lSex.setBounds();
        lFaculty.setBounds();
        lMajor.setBounds();
        lAge.setBounds();
        lMail.setBounds();
        lTel.setBounds();
        tName.setBounds();
        tId.setBounds();
        tSex.setBounds();
        tFaculty.setBounds();
        tMajor.setBounds();
        tAge.setBounds();
        tEmail.setBounds();
        tTel.setBounds();

        save.setBounds();
        */
        save.addActionListener(this);
        //添加标签、文本与按钮
        add(lName);
        add(lId);
        add(lSex);
        add(lFaculty);
        add(lMajor);
        add(lAge);
        add(lEmail);
        add(lTel);
        add(tName);
        add(tId);
        add(tSex);
        add(tFaculty);
        add(tMajor);
        add(tAge);
        add(tEmail);
        add(tTel);

        add(save);
    }
    public void actionPerformed(ActionEvent e){

    }
}
